const { defineConfig } = require("@vue/cli-service");
const AutoImport = require("unplugin-auto-import/webpack");
const Components = require("unplugin-vue-components/webpack");
const { ElementPlusResolver } = require("unplugin-vue-components/resolvers");

//可以配置打包的规则和打包工具等
module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
  chainWebpack: (config) => {
    config.resolve.alias.set("vue-i18n", "vue-i18n/dist/vue-i18n.cjs.js");
  },
  configureWebpack: {
    resolve: {
      alias: {
        utils: "@utils",
      },
    },
    plugins: [
      // ...
      AutoImport({
        resolvers: [ElementPlusResolver()],
      }),
      Components({
        resolvers: [ElementPlusResolver()],
      }),
    ],
  },
  //配置跨域问题
  devServer: {
    client: {
      overlay: false,
    },
    proxy: {
      "^/api": {
        target: process.env.VUE_APP_Proxy_Url,
        pathRewrite: { "/api": "" }, //重写
        changeOrigin: true,
        ws: true,
      },
      "^/role": {
        target: process.env.VUE_APP_Proxy_Url,
        pathRewrite: { "/role": "" }, //重写
      },
    },
  },
});
